﻿@using sBlog.Net.Areas.Admin.Models
@model PostViewModel

@Html.Partial("UpdatePostOrPageStatus", Model)

<div id="updateAjaxStatus">
    
</div>

@using (Html.BeginForm())
{
    <div id="maincontent">
        <div id="left" style="float: left; width: 75%; padding: 15px;">
            @Html.HiddenFor(model => model.Post.PostID)
            @Html.HiddenFor(model => model.Post.PostAddedDate)
            @Html.HiddenFor(model => model.Post.BitlyUrl)
            @Html.HiddenFor(model => model.Post.BitlySourceUrl)
            
            @Html.HiddenFor(model => model.AjaxSaved)

            @{
                var display = "Post";
                if (Model.Post.EntryType == 2)
                {
                    display = "Page";
                }
            }

            <b>@display.ToLower() title</b><br />
            @Html.TextBoxFor(model => model.Post.PostTitle, new { @class = "inputBoxBigPost postTitle" })
            <br /><br />
            <div style="float: left; width: 60%;"> 
                <b>
                    @display.ToLower() content
                </b>
            </div>
            <div class="pull-right">
                <div id="ckeditor_toolbar">
                    <img src="@Url.Content("~/Content/Images/new_window_icon.png")" alt="" title="full screen" style="border:0px; width: 12px; height: 12px" />  <a title="open the editor in full screen" id="fullScreen" href="javascript:void(0)"><span style="text-decoration: underline">full screen</span></a> |
                    <img src="@Url.Content("~/Content/Images/preview.png")" alt="" title="preview" style="border:0px; width: 12px; height: 12px" />  <a title="click for a preview" id="contentPreview" href="javascript:void(0)"><span style="text-decoration: underline">preview</span></a> |
                </div>
                @Html.Action("SyntaxHighlighterHelp", "Admin")
            </div>
            <br /><br />
            @if (PostViewModel.IsMarkDown())
            {
                <div class="mdd_toolbar"></div>
                @Html.TextAreaFor(model => model.Post.PostContent, new {@class = "mdd_editor"})
            }
            else
            {
                @Html.TextAreaFor(model => model.Post.PostContent, new { @class = "adminRichText" })
            }
            <br />
            <b>post url</b>
            <br />
            <h4 class="postUrlLabel" title="click to edit the url">---</h4>
            <span class="postUrlPrefix"></span>@Html.TextBoxFor(model => model.Post.PostUrl, new { @class = "postUrl" })
            @Html.HiddenFor(model => model.Post.PostUrl, new { @class = "postUrlValue" })
            <span class="urlControls">
                <input type="button" id="btnUpdate" value="ok" />&nbsp;<input type="button" id="btnCancel" value="cancel" />
            </span>
            <br /><br />
        </div>

        <div id="right" style="float: left;">
            <div class="panel panel-default">
                <div class="panel-heading">
                   <h3 class="panel-title">Publish Options</h3>
                </div>
                <div class="panel-body">
                    @Html.CheckBoxFor(model => model.Post.IsPrivate, new { @class = "privateChkBox" })
                    @Html.LabelFor(model => model.Post.IsPrivate)
                    <br /><br />
                    <input type="submit" value="Publish" class="publishBtn btn btn-success" />  
                
                    <span>&nbsp;</span>
                
                    @if (Model.Post.EntryType == 1)
                    {
                        @Html.ActionLink("delete post", "DeletePost", "Post", new { postID = Model.Post.PostID }, new { @class = "edit-trash" });
                    }
                    else
                    {
                        @Html.ActionLink("delete page", "DeletePage", "Page", new { postID = Model.Post.PostID }, new { @class = "edit-trash" });
                    }
                </div>
            </div>
            
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">@display Options</h3>
                </div>
                <div class="panel-body">
                    @Html.CheckBoxFor(model => model.Post.UserCanAddComments)
                    @Html.LabelFor(model => model.Post.UserCanAddComments)
                    <br /><br />
                    @{
                    var cssStyle = Model.SharingEnabled ? "" : "sharing-disabled";
                    var title = Model.SharingEnabled ? "" : "Sharing is disabled for this blog. Your setting is overriden by the blog's setting.";
                    }
                    <span title="@title" class="@cssStyle">
                        @Html.CheckBoxFor(model => model.Post.CanBeShared)
                        @Html.LabelFor(model => model.Post.CanBeShared)
                    </span>
                </div>
            </div>
            
            @if (Model.Post.EntryType == 1)
            {
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Categories</h3>
                    </div>
                    <div class="panel-body">
                        @Html.Partial("Categories", Model.Categories)
                    </div>
                </div>                
            }
            
            @if (Model.Post.EntryType == 2)
            {                
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Page Order</h3>
                    </div>
                    <div class="panel-body">
                        @Html.TextBoxFor(model => model.Post.Order, new { @class = "inputBoxBigOrder" })
                    </div>
                </div>
            }

            @Html.HiddenFor(model => model.Post.EntryType)
            
            @if (Model.Post.EntryType == 1)
            {
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Tags</h3>
                    </div>
                    <div class="panel-body">
                        @Html.Partial("Tags", Model.Tags)
                    </div>
                </div>                
            }
        </div>
    </div>
    <input type="hidden" id="isPartiallySavable" value=""/>
}
